﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.Operations;

namespace HPDMAS.UserControls
{
    public partial class MacListesi : System.Web.UI.UserControl
    {
        private int _sehirId = 63;
        private string _macId;
        protected void Page_Load(object sender, EventArgs e)
        {
            GridView_MacListesi.DataSource = MacOperation.MacGetAllGetBySehirId(_sehirId);
            GridView_MacListesi.DataBind();
        }

        protected void GridView_MacListesi_SelectedIndexChanged(object sender, EventArgs e)
        {
            _macId = GridView_MacListesi.SelectedRow.Cells[1].Text;
            Response.Redirect("MacDetay.aspx?macId=" + _macId);
        }

        protected void GridView_MacListesi_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[4].Text = DateTime.Parse(e.Row.Cells[4].Text).ToString("dd/MM/yyyy");
                e.Row.Cells[5].Text = DateTime.Parse(e.Row.Cells[5].Text).ToString("dddd");
                e.Row.Cells[6].Text = DateTime.Parse(e.Row.Cells[6].Text).ToString("hh:mm");
            }
        }

        protected void GridView_MacListesi_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView_MacListesi.PageIndex = e.NewPageIndex;
            GridView_MacListesi.DataBind();
        }
    }
}